print("梅登海格计算工具")
print("请依次输入所求地点经纬度")
print("东经为正，西经为负：")
X = float(input("所求地点经度： "))

Y = float(input("所求地点纬度： "))


if X >= 180 or X < -180 or Y >= 90 or Y < -90 :
    print("输入错误")
    exit()
else:
    #计算坐标映射梅登海格
    A = X/20 + 9
    B = int(A)
    C = Y/10 + 9
    D = int(C)
    A = (A-B)*10
    E = int(A)
    C = (C-D)*10
    F = int(C)
    G = int((A-E)*24)
    H = int((C-F)*24)
    print("Maidenhead is :")
    print("%c %c %d %d %c %c"%(chr(B+65),chr(D+65),E,F,chr(G+97),chr(H+97)))
